<?php

class BShopGoodsCategory extends BaseModel
{
    public $res;
    public $expire;

    public function getSource()
    {
        return "b_shop_goods_category";
    }

    public function get_list()
    {
        $where['conditions'] = 'level_id = 1 and is_show = 0';
        $where['order']      = 'sort asc,id desc';
        $where['columns']    = 'id,category_name';
        $list                = $this->find($where)->toarray();
//        if(!empty($list)){
//            foreach ($list as &$val){
//                $sub['conditions'] = 'p_id = '.$val['id'];
//                $sub['order'] = 'sort asc,id desc';
//                $val['sub_list'] = $this->find($sub)->toarray();
//            }
//        }
        return $list;
    }

    public function goods_categories_parents()
    {
        $condition = 'p_id = 0 ';
        $all       = $this::find(
            array(
                $condition,
                "order"   => 'id asc',
                "columns" => 'id,category_name',
            ));
        return $all;
    }

    public function goods_categories_all($columns = '*')
    {
        $list = $this::find(
            array(
                'conditions' => 'is_show = 0',
                "columns"    => $columns,
            )
        );
        return $list;
    }
}
